import {
  createStore
} from 'vuex'
import VuexPersistence from 'vuex-persist'

const vuexLocal = new VuexPersistence({
	storage: window.localStorage,
    render(state) {
        return { ...state } 
      }
})

export default createStore({
  state() {
    return {
      topBar: 0,
      name: '',
      token: ''
    }
  },
  getters: {
    getTopBar(state) {
      return state.topBar
    },
    getName(state) {
      return state.name
    },
    getToken(state) {
      return state.token
    }
  },
  mutations: {
    setTopBar(state, index) {
      state.topBar = index
    },
    setName(state, name) {
      state.name = name
    },
    setToken(state, token) {
      state.token = token
    }
  },
  actions: {
  },
  modules: {},
  plugins:[vuexLocal.plugin]
})